package com.woniuxy.social.controller;


import com.woniuxy.life.core.api.CommonResult;
import com.woniuxy.social.entity.Community;
import com.woniuxy.social.service.CommunityService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 社区用户表 前端控制器
 * </p>
 *
 * @author John_Yeung
 * @since 2020-09-24
 */
@RestController
@RequestMapping("/social/community")
public class CommunityController {

    @Autowired
    private CommunityService communityService;

    /**修改用户昵称
     *
     * @author John_Yeung
     * @since 2020-09-28
     * @param community
     * @return
     */
    @PutMapping("/updatename")
    @ApiOperation(value = "修改社区用户昵称",notes = "修改社区用户昵称")
    public CommonResult updateCommunityName(@RequestBody Community community){
       return communityService.updateCommunityName(community);
    }

    /**修改用户签名
     *
     * @author John_Yeung
     * @since 2020-09-28
     * @param community
     * @return
     */
    @PutMapping("/updatetag")
    @ApiOperation(value = "更新社区用户签名",notes = "更新社区用户签名")
    public CommonResult updateCommunityTag(@RequestBody Community community){
        return communityService.updateCommunityTag(community);
    }

    /**社区用户签到服务
     *
     * @author John_Yeung
     * @since 2020-09-28
     * @param communityId
     * @return
     */
    @PostMapping("/register/{communityId}")
    @ApiOperation(value = "更新社区用户签名",notes = "更新社区用户签名")
    public CommonResult communityRegister(@PathVariable("communityId") Integer communityId){
        return communityService.communityRegister(communityId);
    }

    /**社区用户签到服务
     *
     * @author John_Yeung
     * @since 2020-09-28
     * @param userId
     * @param communityName
     * @return
     */
    @PostMapping("/insert/{userId}/{communityName}")
    @ApiOperation(value = "新增社区用户",notes = "新增社区用户")
    public CommonResult insertCommunity(@PathVariable("userId") Integer userId,
                                        @PathVariable("communityName") String communityName){
        return communityService.insertCommunity(userId,communityName);
    }
}
